// *** LICENSE HEADER ***
// Filename: ./helperfunctions.h
// This file is part of Nodewarz 0.1
// Nodewarz is a 3d OpenGL strategy game
// Copyright (C) 2007 CZestmyr
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// *** END LICENSE HEADER ***
#ifndef NODEWARS_HELPER_FUNCTIONS_H
#define NODEWARS_HELPER_FUNCTIONS_H

#include <GL/gl.h>
#include <GL/glu.h>
#include <SDL.h>
#include <SDL_net.h>
#include <math.h>
#include "definitions.h"

//Picks a point at the Z plane (z=0) using the given projection matrix and
//Sets the xPos ans yPos variables to the point's x and y coordinates
bool PickAtZPlane(float& xPos, float& yPos, int x, int y);

//Constraints the given float variable against minVal and maxVal
bool Constraintf(float& variable, float minVal, float maxVal);
//Constraints the given integer variable against minVal and maxVal
bool Constrainti(int& variable, int minVal, int maxVal);
//Returns the distance of two points in 2D
float Distancef(float ax, float ay, float bx, float by);

//Safer implementation of std strcpy (in win, there's no strncpy)
char* strcpy_safe_my(char* dest, const char* src, unsigned int dstLength);

//Format an IP address in Network byte order
Uint32 FormatHost(char a, char b, char c, char d);
//Format an IP port number in Network byte order
Uint16 FormatPort(Uint16 port);

#endif
